import 'package:unt/mov_entity.dart';

movEntityFromJson(MovEntity data, Map<String, dynamic> json) {
	if (json['data'] != null) {
		data.data = (json['data'] as List).map((v) => MovData().fromJson(v)).toList();
	}
	if (json['createdAt'] != null) {
		data.createdAt = json['createdAt'] is String
				? double.tryParse(json['createdAt'])
				: json['createdAt'].toDouble();
	}
	if (json['updatedAt'] != null) {
		data.updatedAt = json['updatedAt'] is String
				? double.tryParse(json['updatedAt'])
				: json['updatedAt'].toDouble();
	}
	if (json['id'] != null) {
		data.id = json['id'].toString();
	}
	if (json['originalName'] != null) {
		data.originalName = json['originalName'].toString();
	}
	if (json['imdbVotes'] != null) {
		data.imdbVotes = json['imdbVotes'] is String
				? double.tryParse(json['imdbVotes'])
				: json['imdbVotes'].toDouble();
	}
	if (json['imdbRating'] != null) {
		data.imdbRating = json['imdbRating'].toString();
	}
	if (json['rottenRating'] != null) {
		data.rottenRating = json['rottenRating'].toString();
	}
	if (json['rottenVotes'] != null) {
		data.rottenVotes = json['rottenVotes'] is String
				? double.tryParse(json['rottenVotes'])
				: json['rottenVotes'].toDouble();
	}
	if (json['year'] != null) {
		data.year = json['year'].toString();
	}
	if (json['imdbId'] != null) {
		data.imdbId = json['imdbId'].toString();
	}
	if (json['alias'] != null) {
		data.alias = json['alias'].toString();
	}
	if (json['doubanId'] != null) {
		data.doubanId = json['doubanId'].toString();
	}
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['doubanRating'] != null) {
		data.doubanRating = json['doubanRating'].toString();
	}
	if (json['doubanVotes'] != null) {
		data.doubanVotes = json['doubanVotes'] is String
				? double.tryParse(json['doubanVotes'])
				: json['doubanVotes'].toDouble();
	}
	if (json['duration'] != null) {
		data.duration = json['duration'] is String
				? double.tryParse(json['duration'])
				: json['duration'].toDouble();
	}
	if (json['dateReleased'] != null) {
		data.dateReleased = json['dateReleased'].toString();
	}
	return data;
}

Map<String, dynamic> movEntityToJson(MovEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data'] =  entity.data?.map((v) => v.toJson())?.toList();
	data['createdAt'] = entity.createdAt;
	data['updatedAt'] = entity.updatedAt;
	data['id'] = entity.id;
	data['originalName'] = entity.originalName;
	data['imdbVotes'] = entity.imdbVotes;
	data['imdbRating'] = entity.imdbRating;
	data['rottenRating'] = entity.rottenRating;
	data['rottenVotes'] = entity.rottenVotes;
	data['year'] = entity.year;
	data['imdbId'] = entity.imdbId;
	data['alias'] = entity.alias;
	data['doubanId'] = entity.doubanId;
	data['type'] = entity.type;
	data['doubanRating'] = entity.doubanRating;
	data['doubanVotes'] = entity.doubanVotes;
	data['duration'] = entity.duration;
	data['dateReleased'] = entity.dateReleased;
	return data;
}

movDataFromJson(MovData data, Map<String, dynamic> json) {
	if (json['createdAt'] != null) {
		data.createdAt = json['createdAt'] is String
				? double.tryParse(json['createdAt'])
				: json['createdAt'].toDouble();
	}
	if (json['updatedAt'] != null) {
		data.updatedAt = json['updatedAt'] is String
				? double.tryParse(json['updatedAt'])
				: json['updatedAt'].toDouble();
	}
	if (json['id'] != null) {
		data.id = json['id'].toString();
	}
	if (json['poster'] != null) {
		data.poster = json['poster'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['genre'] != null) {
		data.genre = json['genre'].toString();
	}
	if (json['description'] != null) {
		data.description = json['description'].toString();
	}
	if (json['language'] != null) {
		data.language = json['language'].toString();
	}
	if (json['country'] != null) {
		data.country = json['country'].toString();
	}
	if (json['lang'] != null) {
		data.lang = json['lang'].toString();
	}
	if (json['shareImage'] != null) {
		data.shareImage = json['shareImage'].toString();
	}
	if (json['movie'] != null) {
		data.movie = json['movie'].toString();
	}
	return data;
}

Map<String, dynamic> movDataToJson(MovData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['createdAt'] = entity.createdAt;
	data['updatedAt'] = entity.updatedAt;
	data['id'] = entity.id;
	data['poster'] = entity.poster;
	data['name'] = entity.name;
	data['genre'] = entity.genre;
	data['description'] = entity.description;
	data['language'] = entity.language;
	data['country'] = entity.country;
	data['lang'] = entity.lang;
	data['shareImage'] = entity.shareImage;
	data['movie'] = entity.movie;
	return data;
}